<!--#include file="app/class/blog.class.asp" -->
<%
Dim odb,fso,act
act = Request.Querystring("act")
If act = "up" Then
OpenConn()
odb = Server.MapPath("old.mdb")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(odb) Then
Conn.Execute("drop table Pl") '删除临时表
Conn.Execute("drop table Log") '删除临时表
'Response.End 
sql = "Select * into [Log]  From [;database="&odb&";].Log"
Conn.Execute(sql)
Conn.Execute("ALTER TABLE  [Log]  ALTER COLUMN [id] COUNTER CONSTRAINT MyPrimaryKey PRIMARY KEY")
sql = "Select * into [Pl]  From [;database="&odb&";].Pl"
Conn.Execute(sql)
Conn.Execute("ALTER TABLE [Pl]  ALTER COLUMN [pid] COUNTER CONSTRAINT MyPrimaryKey PRIMARY KEY")
Conn.Execute("ALTER TABLE [Log] ADD [title] Text(100)") 
Conn.Execute("ALTER TABLE [Log] ADD [summ] Memo") 
Conn.Execute("ALTER TABLE [Log] ADD [pass] Text(8)") 
Conn.Execute("update Log set summ=left(content,150)") '更新
Conn.Execute("update Log set title='',pass=''") '更新
Conn.Execute("update Log set pic='' where isnull(pic)") '更新
sql = "Select * into [link]  From [;database="&odb&";].link"
Conn.Execute(sql)
Set rs= conn.execute("select * from link where id=1")
Conn.Execute("update [wid] set html='"&rs("link")&"' where id=3") '更新
rs.close
Set rs= conn.execute("select * from link where id=3")
Conn.Execute("update [wid] set html='"&rs("link")&"' where id=4") '更新
rs.close 
Conn.Execute("drop table link") '删除临时表
sql = "ALTER TABLE Pl ADD CONSTRAINT gx1 FOREIGN KEY ([cid]) REFERENCES Log ([id]) ON UPDATE CASCADE ON DELETE CASCADE"
Conn.Execute(sql)
Response.Write "数据库升级成功,请删除旧数据库（删除前请备份数据）" 
else
Response.Write "旧数据库文件不存在"
Response.write "请将v3数据库复制到本目录并命名为old.mdb<br>"
Response.write "<a href='?act=up'>升级</a>"
Response.End 
end if
Set fso = Nothing
Else
Response.write "请将v3数据库复制到本目录并命名为old.mdb<br>"
Response.write "<a href='?act=up'>升级</a>"
End if
%>